<%--
  Created by IntelliJ IDEA.
  User: MSI
  Date: 2022/5/6
  Time: 15:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="/js/jquery-3.1.1.min.js"></script>
</head>
<body>
<h1>数据库操作</h1>
<label>查询数据库</label>
<button type="button" onclick="add()">新增</button>
<button type="button" onclick="update()">更新</button>
<button type="button" onclick="query()">查询</button>
</body>
<script>
    function add(){
        $.ajax({
            url:"/stuAjax/add",
            type:"post",
            dataType:"json",
            success:function (data){
                console.log(data);
                $("#info").text(data.info);
                if (data.success){
                    //回到 index页面
                    window.location.href="/test/index";
                }
            },
            error:function (data){
                console.log("连接服务器失败")
            }
        })
    }function update(){
        $.ajax({
            url:"/stuAjax/update",
            type:"post",
            dataType:"json",
            success:function (data){
                console.log(data);
                $("#info").text(data.info);
                if (data.success){
                    //回到 index页面
                    window.location.href="/test/index";
                }
            },
            error:function (data){
                console.log("连接服务器失败")
            }
        })
    }function query(){
        $.ajax({
            url:"/stuAjax/queryAll",
            type:"post",
            dataType:"json",
            success:function (data){
                console.log(data);
                $("#info").text(data.info);
                if (data.success){
                    //回到 index页面
                    window.location.href="/test/index";
                }
            },
            error:function (data){
                console.log("连接服务器失败")
            }
        })
    }
</script>
</html>
